#!/bin/bash
# For all the following commands HOME should be set to the directory that has .my.cnf file with password information.

# Flexible parameter to grab global variables. On the frontend side, use keys like mysql.status[Com_insert].
# Key syntax is mysql.status[variable].
#当前连接数   可以使用键值   mysql.status[Threads_connected] 
#当前正在运行连接  mysql.status[Threads_running] 
#请参见：
#http://stackoverflow.com/questions/7432241/mysql-show-status-active-or-total-connections
# function getMysqlStatus(){
#     VALUE=`HOME=${MYSQL_HOME_PATH} mysqladmin ping 2> /dev/null | grep -c alive`
#     echo ${VALUE}
# }
MYSQLD=`ps ux | grep -v grep |grep -c mysqld`

if [ ${MYSQLD} -lt 1 ]; then 
    exit 0
fi

function getMysqlossdb(){
    VALUE=`HOME=${MYSQL_HOME_PATH} mysql -e "show databases"  2> /dev/null | grep -c ossdb`
    echo ${VALUE}
}

if [[ $(getMysqlossdb) = "1" ]]; then
    HOME=/opt/fonsview/3RD/zabbix mysql -e "show full processlist" |grep ossdb|wc -l
fi